package service

import (
	"server/global"
	"server/utils/request"
)

func EmqxGetClientsOnline(ClientID string) int {
	url := global.CONFIG.Emqx.ApiUrl + "/clients/" + ClientID
	res := request.GetByBasicAuth(url, global.CONFIG.Emqx.Username, global.CONFIG.Emqx.Password)
	if len(res) > 100 {
		return 1
	} else {
		return 0
	}
}

func EmqxGetClients() string {
	url := global.CONFIG.Emqx.ApiUrl + "/clients"
	res := request.GetByBasicAuth(url, global.CONFIG.Emqx.Username, global.CONFIG.Emqx.Password)
	return res
}

// func EmqxMqttPublish(client_id string, topic string, payload string) int {
// 	url := setting.MqttSetting.BaseUrl + "/mqtt/publish"
// 	fmt.Println(url)
// 	res := http.PostByBasicAuth(url, setting.MqttSetting.UserName, setting.MqttSetting.Password)
// 	fmt.Println(res)

// 	if len(res) > 100 {
// 		return 1
// 	} else {
// 		return 0
// 	}
// }
